/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.epsi.montpellier.ejbmodulecrm.heavy.heavyclientcrm;

import fr.epsi.montpellier.ejbmodulecrm.heavy.facade.FacadeClientBeanRemote;
import fr.epsi.montpellier.ejbmodulecrm.heavy.facade.FacadeUtilisateurBeanRemote;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.swing.JFrame;

/**
 *
 * @author Clément
 */
public class HeavyClientCRM {

    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            Properties props = new Properties();
            props.setProperty("java.naming.factory.initial",
            "com.sun.enterprise.naming.SerialInitContextFactory");
            props.setProperty("java.naming.factory.url.pkgs",
            "com.sun.enterprise.naming");
            props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
            // optional. Defaults to localhost. Only needed if web server is running
            // on a different host than the appserver
            props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
            // optional. Defaults to 3700. Only needed if target orb port is not 3700.
            props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

            InitialContext ic = new InitialContext(props);
            /*ConvertisseurMonaieRemote c = (ConvertisseurMonaieRemote) ic.lookup("java:global/EJBModule1/ConvertisseurMonaie!fr.epsi.montpellier.java.EJBsession.convertisseur.ConvertisseurMonaieRemote");
            System.out.println(c.getEuro(1000.0));*/

            FacadeClientBeanRemote facadeClient = (FacadeClientBeanRemote)
            ic.lookup("java:global/EJBModuleCRM/FacadeClientSessionBean!fr.epsi.montpellier.ejbmodulecrm.heavy.facade.FacadeClientBeanRemote");
            
            FacadeUtilisateurBeanRemote facadeUtilisateur = (FacadeUtilisateurBeanRemote)
            ic.lookup("java:global/EJBModuleCRM/FacadeUtilisateurSessionBean!fr.epsi.montpellier.ejbmodulecrm.heavy.facade.FacadeUtilisateurBeanRemote");
            
            
            new HeavyJFrame(facadeClient, facadeUtilisateur);
            /*Client c = new Client();
            c.setNom("SMITH");
            c.setPrenom("John");
            c.setAdresse("main street");
            c.setCp(12345);
            c.setVille("NYC");
            facade.creerClient(c);
            
            c.setNom("DUPONT");
            facade.creerClient(c);
            
            List<Client> mesClients = facade.listerClients();
            
            for (Client cli : mesClients) {
                System.out.println(cli.toString());
            }*/
            
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}
